app.controller('vipMessageNewpwdPageCtrl',function($scope,$state,PopupService,$stateParams,$http,$myconfig,$timeout,$mydialog,$ionicConfig){
    //接收上一面传送的参数
    var change_password = JSON.parse($stateParams.NewPwd);
    $scope.change_password = {
        mobile:change_password.mobile,
        code:change_password.code_type
    };
    // console.log($scope.newPhon);

    //执行修改函数
    $scope.saveChange = function(){
        $http.post($myconfig.api.base_host + '/users/change_password',{
            "mobile":$scope.change_password.mobile,
            "password":$scope.change_password.password,
            "comf_password":$scope.change_password.comf_password,
            "code":$scope.change_password.code
        }).then(function(res){
            if(res.data.success){
                $scope.success_text = '更改成功，请重新登录';
                $mydialog.success($scope);
                localStorage.clear();
                $state.go('app.login');
            }else{
                $scope.err = res.data.data;
                $mydialog.fail($scope);
            }
        })
    };

    $scope.$on('$ionicView.enter', function(){

        $ionicConfig.views.swipeBackEnabled(false);

    });
});
